package com.hefu.virtuallife.ui.foods.fragment;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.dz.utlis.ScreenUtils;
import com.hefu.virtuallife.R;
import com.hefu.virtuallife.baseui.BaseFragment;
import com.hefu.virtuallife.recyclerViewdivider.HDividerItemDecoration;
import com.hefu.virtuallife.ui.foods.adapter.PrePlanAdapter;
import com.hefu.virtuallife.ui.foods.bean.PlanFoodBean;
import com.hefu.virtuallife.utils.UiCompat;
import com.scwang.smartrefresh.header.MaterialHeader;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * creat_user: zhengzaihong
 * email:1096877329@qq.com
 * creat_date: 2018/8/11
 * creat_time: 13:34
 * describe: 预订菜单
 **/

public class MyPreMenueFragment extends BaseFragment implements OnRefreshLoadMoreListener {

    @BindView(R.id.header)
    MaterialHeader header;
    @BindView(R.id.recycler_foods)
    RecyclerView recyclerFoods;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;

    private PrePlanAdapter prePlanAdapter;

    public MyPreMenueFragment(){}



    @Override
    protected int getContentLayoutId() {
        return R.layout.fragment_plan_foods;
    }

    @Override
    protected void initData() {
        super.initData();


        refreshLayout.setOnLoadMoreListener(this);
        refreshLayout.setOnRefreshListener(this);
        refreshLayout.autoRefresh();
        refreshLayout.setEnableLoadMore(false);

        recyclerFoods.setLayoutManager(new LinearLayoutManager(mContext));

        prePlanAdapter = new PrePlanAdapter(mContext);
        recyclerFoods.setAdapter(prePlanAdapter);
        prePlanAdapter.setType(0);


    }


    @Override
    public void onLoadMore(RefreshLayout refreshLayout) {

    }

    @Override
    public void onRefresh(RefreshLayout refreshLayout) {
        getPlanFood();

        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();
    }


    private void getPlanFood() {

        List<PlanFoodBean> listdata = new ArrayList<>();

        for (int i = 0; i < 4; i++) {
            PlanFoodBean planFoodBean = new PlanFoodBean();
            listdata.add(planFoodBean);
        }

        prePlanAdapter.replaceData(listdata);
    }
}
